#include <stdio.h>
#include <stdlib.h>
int main()
{
    int n, i = 1, j, a[100][100];
    FILE *fp; 
    scanf("%d", &n);

    for (i = 0; i < n; i++)
    {
        a[i][0] = 1;
        a[i][i] = 1;
        if (n > 2 )
        {
            for (j = 1; j < i; j++)
            {
                a[i][j] = a[i - 1][j] + a[i - 1][j - 1];
            }
        }
    }

    for (i = 0; i < n; i++)
    {
        for (j = 0; j <= i; j++)
        {
            printf("%4d", a[i][j]);
        }
        printf("\n");
    }
    
    if((fp=fopen("a.txt","w"))==NULL)
    {
		printf("Can not open the file.\n");
		exit(0);
	}
	else
	{
		for (i = 0; i < n; i++)
	    {
	        for (j = 0; j <= i; j++)
	        {
	            fprintf(fp,"%4d", a[i][j]);
	        }
	        fprintf(fp,"\n");
	    }
	}
	fclose(fp);
    return 0;
}

